<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<link rel="stylesheet" href="lib/jquery_datatables_lastest/media/css/demo_page.css" type="text/css">
<link rel="stylesheet" href="lib/jquery_datatables_lastest/media/css/demo_table.css" type="text/css">
<link type="text/css" rel="stylesheet" href="lib/jquery_ui_lastest/themes/base/jquery_ui_lastest.css" />
<link rel="stylesheet" href="lib/jquery_fancybox_lastest/fancybox/jquery_fancybox_lastest.css" type="text/css" />
<link rel="stylesheet" href="lib/sheet.css" type="text/css">
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_fancybox_lastest/fancybox/jquery_fancybox_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_timers_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_ui_lastest/jquery_ui_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_datatables_lastest/media/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
	$(function() {
				//$(".contable").addClass("ct");	//载入table样式
				//$(".contable th").addClass("ch");	//载入th样式
				//$(".contable td").addClass("cd");	//载入td样式

				//$(".contable tbody tr:odd").addClass("alt");	//对表格主体内单数行进行样式应用

				//$(".contable tbody tr").hover(function(){	//对返回的dom进行hover事件捕获
				//	$(this).addClass("over");	//添加css样式
				//},function(){
				//	$(this).removeClass("over");	//移除css样式
				//});

		function fnFormatDetails ( oTable, nTr )
		{
			var aData = oTable.fnGetData( nTr );
			var sOut = '<table cellpadding="6" cellspacing="0" border="0">';
			sOut +='<tr><td>货单</td>';
			sOut +='<td>派单时间</td>';
			sOut +='<td>接单时间</td>';
			sOut +='<td>提箱时间</td></tr>';
			//sOut += '<tr><td>Rendering engine:</td><td>'+aData[1]+' '+aData[4]+'</td></tr>';
			//sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
			//sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
			
			$.ajax({
				url: "readProgress.asp",
				async: false,
				data: {"progress_cl":aData[1]},
				success: function(data){
 					$.each(data,function(i,item){
						sOut +='<tr><td>'+item.progress_yb+'</td>';
						sOut +='<td>'+item.progress_start+'</td>';
						sOut +='<td>'+item.progress_accept+'</td>';
						sOut +='<td>'+item.progress_tx+'</td></tr>';
					});
				}
			});
			
			
			//$.getJSON("readProgress.asp",{"progress_cl":aData[1]},function(data){
			//	$.each(data,function(i,item){
					//alert(item.progress_yb);
			//		sOut +='<tr><td>'+item.progress_yb+'</td>';
			//		sOut +='<td>'+item.progress_start+'</td>';
			//		sOut +='<td>'+item.progress_accept+'</td>';
			//		sOut +='<td>'+item.progress_tx+'</td></tr>';
				
				
			//	});
			
			//});
			
			
			sOut += '</table>';
			
			return sOut;
		}
				
				
				
				
				
		var nCloneTh = document.createElement( 'th' );
		var nCloneTd = document.createElement( 'td' );
		nCloneTd.innerHTML = '<img src="lib/jquery_datatables_lastest/examples/examples_support/details_open.png">';
		nCloneTd.className = "center";
		
		$('.contable thead tr').each( function () {
			this.insertBefore( nCloneTh, this.childNodes[0] );
		} );
		
		$('.contable tbody tr').each( function () {
			this.insertBefore(  nCloneTd.cloneNode( true ), this.childNodes[0] );
		} );


		oTable = $('.contable').dataTable({
			"iDisplayLength": 50,
			"oLanguage": {
				"sUrl": "lib/jquery_datatables_lastest/media/language/zh_CN.txt"
			},
			"aoColumnDefs": [
				{ "bSortable": false, "aTargets": [ 0 ] }
			],
			"aaSorting": [[1, 'asc']]

		
		});

		$('.contable tbody td img').live('click', function () {
			var nTr = this.parentNode.parentNode;
			if ( this.src.match('details_close') )
			{
				/* This row is already open - close it */
				this.src = "lib/jquery_datatables_lastest/examples/examples_support/details_open.png";
				oTable.fnClose( nTr );
			}
			else
			{
				/* Open this row */
				this.src = "lib/jquery_datatables_lastest/examples/examples_support/details_close.png";
				oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
			}
		} );
				
				
				
				
				
				$("a.iframe").fancybox({
					'width':660,
					'height':450,
					'speedOut':0,
					'hideOnOverlayClick':false,
					'type':'iframe'
				});
		$("body").everyTime('1s','A',function(){
			getProgress();
		},1,true);
		$("#today").click(function(){
			getProgress();
		});
		
		function getProgress(){
		
			$.getJSON("readProgress.asp",{"query":$("#today").val()},function(data){
				var clid=0;
				var p=$("#accordion");
				var h="";
				p.html("");
				$.each(data,function(i,item){
					if(item.progress_cl!=clid){
						var ybid=true;
						if(clid!=0){h+="</ul></div>";}
						h+="<h3><a href='#'>车牌:"+item.cph+" 位置</a></h3><div>";
						clid=item.progress_cl;
					}
					if(ybid){
						h+="<div>货单</div><ul>";
						ybid=false;
					}
					h+="<li>"+item.progress_yb+"</li>";
					
				});
				p.html(h);
				p.accordion({
					collapsible: true,
					autoHeight: false
				});
		
			});
		
		
		};
	});
</script>	
</head>
<%
If Not Session("MM_Reg") Then
	response.write("您没有登陆，请登陆后使用!<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.end
End If
if Session("MM_Flag")<1 then
	response.write("您没有查询权限！<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.End
end if
if Session("MM_Post")<>1 And Session("MM_Post")<>0 Then
	response.write("您没有此岗位操作权限！<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.End
end If
%>

<body>
<button id="today" type="button" value="<%=date()%>">今天派单</button>

<table class="contable display">
<thead>
  <tr>
      <th>序号</th>
      <th>车辆名</th>
      <th>车牌号</th>
      <th>目前位置</th>
      <th>工单数</th>
    </tr>
	</thead>
	<tbody>
	<%
	Set rs_progress = Server.CreateObject("ADODB.Recordset")
	sql = "select clid,clm,cph,cl_reverse,num from (SELECT progress_cl,count(progress_cl) as num FROM progress  where progress_start>date() group by progress_cl) as a left join cl on a.progress_cl=cl.clid"
	rs_progress.Open sql,conn,1,1
	do while not rs_progress.eof
	%>
		<tr>
			<td><%=rs_progress("clid")%></td>
			<td><%=rs_progress("clm")%></td>
			<td><%=rs_progress("cph")%></td>
			<td><%=rs_progress("cl_reverse")%></td>
			<td><%=rs_progress("num")%></td>
		</tr>
	<%
		rs_progress.movenext
	loop
	rs_progress.close
	set rs_progress=nothing
	%>
	</tbody>
</table>

<p></p>
<div id="accordion"></div>
<%
	Set rs = Server.CreateObject("ADODB.Recordset")
	'sql = "SELECT * FROM (progress LEFT JOIN cl ON progress.progress_cl = cl.clid) LEFT JOIN yb ON progress.progress_yb = yb.id order by progress_id desc"
	sql = "SELECT * FROM (progress LEFT JOIN cl ON progress.progress_cl = cl.clid) LEFT JOIN yb ON progress.progress_yb = yb.id where progress_start>date() order by progress_id desc"
	rs.Open sql,conn,1,1
%>


<table>
<thead>
  <tr>
      <th>ID</th>
      <th>车辆</th>
      <th>货单</th>
      <th>派单时间</th>
      <th>目前状态</th>
      <th>目前位置</th>
    </tr>
	</thead>
	<% while not rs.eof %>
	<tbody>
  	<tr>
      <td><%=rs("progress_id")%></td>
      <td><a href="deal.asp?clid=<%=rs("clid")%>"><%=rs("cph")%></a></td>
      <td><a class="iframe" href="view_cd.asp?id=<%=rs("progress_yb")%>"><%=rs("progress_yb")%></a></td>
      <td><%=rs("progress_start")%></td>
      <td><%
						if rs("progress_accept")<>"" then
							response.write("已经接单，准备去提箱")
						elseif rs("progress_tx")<>"" then
							response.write("已经提箱，准备去厂装箱")
						elseif rs("progress_reach")<>"" then
							response.write("已经到厂，装箱中")
						elseif rs("progress_left")<>"" then
							response.write("已经离厂，去港口了")
						elseif rs("progress_arrival")<>"" then
							response.write("已经进港，准备装船")
						elseif rs("progress_end")<>"" then
							response.write("已经完成货单")
						else
							response.write("还未接单")
						end if
			%></td>
       <td></td>
   </tr>
	</tbody>
	<% rs.movenext
	wend
	rs.close
	conn.close
	Set conn=nothing
	%>
  </table>
</body>
</html>
